

<template>

  <div >
       <el-button  class="butB_Sel"  @click="printBtn()">打印</el-button>
    <div class="app-container" id="printcons" >
      <div class="" style="width:400px;height:250px;margin:auto;padding: 0px 20px;padding-top:20px;
	  font-size:12px">
      <div >
		 <h2 style="text-align: center;margin: 0 5px;">{{tabeldata.title}}</h2>
		
												<p style=";width:50%;float: left;">挂号时间
												<span style="">{{tabeldata.time}}</span>
												</p>
												<p style=";width:50%;    float: left;">门诊号
												<span style="">{{tabeldata.patient_no}}</span>
												</p>
                                              
											
												<table border="1"   cellspacing="0" cellpadding="0">
												   <tr >
												    <td style="width:60px; height: 20px">姓名</td>
												    <td style="width:60px; height: 20px">{{tabeldata.name}}</td>
												    <td style="width:60px; height: 20px">年龄</td>
												    <td style="width:60px; height: 20px">{{tabeldata.age}}</td>
												   </tr>
												   <tr >
												     <td style="width:60px; height: 20px">性别</td>
												     <td style="width:60px; height: 20px">{{tabeldata.gender==1?'男':tabeldata.gender==2?"女":'未知'}}</td>
												     <td style="width:60px; height: 20px">病人来源</td>
													 <td style="width:60px; height: 20px">{{tabeldata.source}}</td>
												   </tr>
												    <tr >
												     <td style="width:60px; height: 20px">挂号种类</td>
												     <td style="width:60px; height: 20px">{{tabeldata.look_type==1?'初诊':'复诊'}} </td>
												     <td style="width:60px; height: 20px">挂号科室</td>
												     <td style="width:60px; height: 20px">{{tabeldata.dept}}</td>
												     </tr>
												 
													     <tr >
												     <td style="width:60px; height: 20px">挂号医生</td>
												     <td style="width:60px; height: 20px">{{tabeldata.doctor}}</td>
												     <td style="width:60px; height: 20px">挂号费</td>
												     <td style="width:60px; height: 20px">{{tabeldata.pay_amount}}</td>
												     </tr>
												
													     <!-- <tr  v-if="tabeldata.fee[0].lenght>1">
												     <td style="width:60px; height: 20px">{{tabeldata.fee[1].name}}</td>
												     <td style="width:60px; height: 20px">{{tabeldata.fee[1].price}}</td>
												      <td style="width:60px; height: 20px">{{tabeldata.fee[2].name}}</td>
												     <td style="width:60px; height: 20px">{{tabeldata.fee[2].price}}</td>
												     </tr> -->
												   <tr >
												     <td style="width:60px; height: 20px">{{tabeldata.payment==1?'现金':tabeldata.payment==2?'支付宝':tabeldata.payment==3?'微信':tabeldata.payment==4?'银联':tabeldata.payment==7?'挂账':'其他'}}</td>
						     						    <td style=" height: 20px" rowspan="3">
															 {{tabeldata.pay_amount}}
														 </td>
                                                         </tr>
												</table>
												<p style="">操作员: 
													<span  style="margin: 0 0.3125rem;">
												{{tabeldata.opt_name}}
												 </span>
							</p>
											</div>	
				
		        </div>
                 </div>
  </div>
</template>
<script>


import { getdictIndex, } from "@/api/register";
export default {
		props:['id'],
  data() {
    return {
  tabeldata:{},
  sourcelist:[],
   dayin:false
    };
  },
  
  mounted(){
	  this.getindex()
   this.getpint()
  },
   watch: {
 
    id(n) {
			 this.getpint()
	}},
  methods: {
	  getindex(){
		  	getdictIndex({group_id:'40'}).then(res=>{
				let data = res.data;
				  data.forEach((item, key) => {
				if(item.id==40){
            
             this.sourcelist=item.items;
            } 
			 })
			  })
	  },
	  getpint(){
		  	       this['_API'].getPrintReport({id:this.id}).then(res=>{
                            if(res.code==200){
                               this.tabeldata=res.data
								this.tabeldata.source=this.mapxing(this.tabeldata.source)
								
							}
                    })
	  },
	 
	    mapxing(num) {
      var art = "";
         this.sourcelist.map(function(value,i,array){
            
            if (value.id == num) {
          art = value.name;
        }
        
       })
	   console.log(art)
        return art;  
    },
        printBtn(e) {
            this.dayin=true
         setTimeout(() => {
      this.dayinfun()
     }, 200);
     
    },
        dayinfun(){
             this.remove_ie_header_and_footer();
      let subOutputRankPrint = document.getElementById("printcons");
      console.log(subOutputRankPrint.innerHTML);
      let newContent = subOutputRankPrint.innerHTML;
      let oldContent = document.body.innerHTML;
      document.body.innerHTML = newContent;
      window.print();
      window.location.reload();
      document.body.innerHTML = oldContent;
      return false;
        },
    //去掉页眉和页脚
    remove_ie_header_and_footer() {
      var hkey_path;
      hkey_path =
        "HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
      try {
        var RegWsh = new ActiveXObject("WScript.Shell");
        RegWsh.RegWrite(hkey_path + "header", "");
        RegWsh.RegWrite(hkey_path + "footer", "");
      } catch (e) {}
    },

    
    
  },
   
};
</script>
<style media="print">
				@page {
				  size: auto; /* auto is the initial value */
				  margin: 0mm; /* this affects the margin in the printer settings */
				}
				@media print {
				}
				body {
				  -webkit-print-color-adjust: exact;
				}
				   	#printcons>>>td{
						width:60px;
                        height: 20px!important;
				
						/* border: 0.5px solid #000000; */
						padding: 0rem;
						margin: 0rem;
						text-align: center;
					}
				</style>
<style lang='scss' scoped>
#printcons>>> tr{
						height: 20px!important;
						padding: 20px 10px;
						margin: 0rem;
						
					}
                    	#printcons>>>td{
						width:60px;
                        height: 20px!important;
						height: 100%;
						/* border: 0.5px solid #000000; */
						padding: 0rem;
						margin: 0rem;
						text-align: center;
					}
		


</style>